﻿package mortal.game.resource.tableConfig
{
    import Message.Client.*;
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import com.gengine.utils.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class DefenseCopyShopConfig extends Object
    {
        private var _map:Dictionary;
        private var _allEquipItem:Array;
        private var _allScrollItem:Array;
        private static var _instance:DefenseCopyShopConfig;

        public function DefenseCopyShopConfig()
        {
            this._map = new Dictionary();
            if (_instance != null)
            {
                throw new Error("DefenseCopyShopConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_defense_copy_shop_sell.json");
            this.write(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TDefenseCopyShopSell = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TDefenseCopyShopSell();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                if (!this._map)
                {
                    this._map = new Dictionary();
                }
                if (!this._map.hasOwnProperty(_loc_2.sellType))
                {
                    this._map[_loc_2.sellType] = new Dictionary();
                }
                this._map[_loc_2.sellType][_loc_2.itemCode] = _loc_2;
            }
            return;
        }// end function

        public function getConfigBySellType(param1:int) : Dictionary
        {
            return this._map[param1];
        }// end function

        public function getItem(param1:int, param2:int) : TDefenseCopyShopSell
        {
            return this._map[param1][param2] as TDefenseCopyShopSell;
        }// end function

        public function get allEquipItem() : Array
        {
            if (this._allEquipItem == null)
            {
                this._allEquipItem = ArrayUtil.DictAsArr(this.getConfigBySellType(EDefenseCopyShopSellType._EDefenseCopyShopSellEquip));
            }
            return this._allEquipItem;
        }// end function

        public function get allScrollItem() : Array
        {
            if (this._allScrollItem == null)
            {
                this._allScrollItem = ArrayUtil.DictAsArr(this.getConfigBySellType(EDefenseCopyShopSellType._EDefenseCopyShopSellScroll));
            }
            return this._allScrollItem;
        }// end function

        public static function get instance() : DefenseCopyShopConfig
        {
            if (_instance == null)
            {
                _instance = new DefenseCopyShopConfig;
            }
            return _instance;
        }// end function

    }
}
